package com.marketing.tenant.dto;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;

/**
 * 批量保存租户配置请求DTO
 */
public class BatchSaveTenantConfigRequest {

    /**
     * 租户ID
     */
    @NotNull(message = "租户ID不能为空")
    private Long tenantId;

    /**
     * 配置列表
     */
    @NotEmpty(message = "配置列表不能为空")
    @Valid
    private List<ConfigItem> configs;

    // 手动添加getter和setter方法
    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public List<ConfigItem> getConfigs() {
        return configs;
    }

    public void setConfigs(List<ConfigItem> configs) {
        this.configs = configs;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BatchSaveTenantConfigRequest that = (BatchSaveTenantConfigRequest) o;
        return Objects.equals(tenantId, that.tenantId) &&
                Objects.equals(configs, that.configs);
    }

    @Override
    public int hashCode() {
        return Objects.hash(tenantId, configs);
    }

    @Override
    public String toString() {
        return "BatchSaveTenantConfigRequest{" +
                "tenantId=" + tenantId +
                ", configs=" + configs +
                '}';
    }

    /**
     * 配置项
     */
    public static class ConfigItem {
        /**
         * 配置组
         */
        @NotNull(message = "配置组不能为空")
        private String configGroup;

        /**
         * 配置键
         */
        @NotNull(message = "配置键不能为空")
        private String configKey;

        /**
         * 配置值
         */
        private String configValue;

        /**
         * 值类型
         */
        private String valueType = "STRING";

        /**
         * 是否加密
         */
        private Integer isEncrypted = 0;

        /**
         * 配置描述
         */
        private String description;

        // 手动添加getter和setter方法
        public String getConfigGroup() {
            return configGroup;
        }

        public void setConfigGroup(String configGroup) {
            this.configGroup = configGroup;
        }

        public String getConfigKey() {
            return configKey;
        }

        public void setConfigKey(String configKey) {
            this.configKey = configKey;
        }

        public String getConfigValue() {
            return configValue;
        }

        public void setConfigValue(String configValue) {
            this.configValue = configValue;
        }

        public String getValueType() {
            return valueType;
        }

        public void setValueType(String valueType) {
            this.valueType = valueType;
        }

        public Integer getIsEncrypted() {
            return isEncrypted;
        }

        public void setIsEncrypted(Integer isEncrypted) {
            this.isEncrypted = isEncrypted;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            ConfigItem that = (ConfigItem) o;
            return Objects.equals(configGroup, that.configGroup) &&
                    Objects.equals(configKey, that.configKey) &&
                    Objects.equals(configValue, that.configValue) &&
                    Objects.equals(valueType, that.valueType) &&
                    Objects.equals(isEncrypted, that.isEncrypted) &&
                    Objects.equals(description, that.description);
        }

        @Override
        public int hashCode() {
            return Objects.hash(configGroup, configKey, configValue, valueType, isEncrypted, description);
        }

        @Override
        public String toString() {
            return "ConfigItem{" +
                    "configGroup='" + configGroup + '\'' +
                    ", configKey='" + configKey + '\'' +
                    ", configValue='" + configValue + '\'' +
                    ", valueType='" + valueType + '\'' +
                    ", isEncrypted=" + isEncrypted +
                    ", description='" + description + '\'' +
                    '}';
        }
    }
}